"""
运行
版本1.0
2020-7-27 11:48:06
by f.s.x.

将多个文件合成一个
附带插入id和排序功能

"""
import json
import os
import tools.merge.merge as me
file_list =[]
i = int(input("请输入文件的数量：\n > "))
for a in range(1,i+1):
    while True:
        fn = input("请输入文件路径(第 %d 个，共 %d 个)：\n > "%(a, i)).replace('"','')
        print("正在验证...",end='')
        if os.path.isfile(fn) is False:
            print("错误的路径!")
            continue
        else:
            print("正确的路径!")
            break
    file_list.append(fn)
out_put_file_name = input("请输入输出文件路径")

print(file_list)
res = me.merge(in_list=file_list, out_put_file_name_str=out_put_file_name)

w = json.dumps(res, ensure_ascii=False, indent=4)
print("正在写入")
with open(out_put_file_name,'w+' ,encoding='utf-8') as f:
    f.write(w)
